﻿#include "module_interface.h"
#include "hmi_library_export.h"
#include "hmi_module.h"

// 确保编译器能看到HMIModule的实现
extern HMIModule* createHMIModuleInstance(QWidget* ui, ModbusManager* modbusManager, QObject* parent);

extern "C" {

// 导出函数：创建HMI模块
HMI_LIBRARY_API IModule* createModule(QWidget* ui, ModbusManager* modbusManager, QObject* parent)
{
    return createHMIModuleInstance(ui, modbusManager, parent);
}

// 导出函数：获取模块名称
HMI_LIBRARY_API const char* getModuleName()
{
    return "HMI";
}

// 导出函数：创建工厂
HMI_LIBRARY_API IModuleFactory* createFactory()
{
    class HMIModuleFactory : public IModuleFactory
    {
    public:
        IModule* createModule(QWidget* ui, ModbusManager* modbusManager, QObject* parent = nullptr) override
        {
            return new HMIModule(ui, modbusManager, parent);
        }
        
        QString getModuleName() const override
        {
            return QString(u8"HMI");
        }
    };
    
    return new HMIModuleFactory();
}

}
